import 'package:flutter/material.dart';

class TabsWidget extends StatefulWidget {
  const TabsWidget({super.key, this.onChanged});
  final Function(int)? onChanged;
  @override
  State<TabsWidget> createState() => _TabsWidgetState();
}

class _TabsWidgetState extends State<TabsWidget> {
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 220,
      height: 30,
      decoration: BoxDecoration(
        color: const Color(0xFF3F3E44),
        borderRadius: BorderRadius.circular(33),
      ),
      child: Row(children: [
        GestureDetector(
          child: Container(
            width: 110,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: _currentIndex == 0
                  ? const Color(0xFFFFFFFF)
                  : Colors.transparent,
              borderRadius: BorderRadius.circular(33),
            ),
            child: Text(
              '基础模式',
              style: TextStyle(
                color:
                    _currentIndex == 0 ? const Color(0xFF000000) : Colors.white,
                fontSize: 13,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          onTap: () => {
            setState(() {
              _currentIndex = 0;
              widget.onChanged!(_currentIndex);
            })
          },
        ),
        GestureDetector(
          child: Container(
            width: 110,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: _currentIndex == 1
                  ? const Color(0xFFFFFFFF)
                  : Colors.transparent,
              borderRadius: BorderRadius.circular(33),
            ),
            child: Text(
              '专业模式',
              style: TextStyle(
                color:
                    _currentIndex == 1 ? const Color(0xFF000000) : Colors.white,
                fontSize: 13,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          onTap: () => {
            setState(() {
              _currentIndex = 1;
              widget.onChanged!(_currentIndex);
            })
          },
        ),
      ]),
    );
  }
}
